package com.ruoyi.project.module.deptBan.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.deptBan.domain.DeptBan;
import com.ruoyi.project.module.deptBan.service.IDeptBanService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 班级成员管理 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-10-31
 */
@Controller
@RequestMapping("/module/deptBan")
public class DeptBanController extends BaseController
{
    private String prefix = "module/deptBan";
	
	@Autowired
	private IDeptBanService deptBanService;
	
	@RequiresPermissions("module:deptBan:view")
	@GetMapping()
	public String deptBan()
	{
	    return prefix + "/deptBan";
	}
	
	/**
	 * 查询班级成员管理列表
	 */
	@RequiresPermissions("module:deptBan:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(DeptBan deptBan)
	{
		startPage();
        List<DeptBan> list = deptBanService.selectDeptBanList(deptBan);
		return getDataTable(list);
	}
	
	/**
	 * 新增班级成员管理
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存班级成员管理
	 */
	@RequiresPermissions("module:deptBan:add")
	@Log(title = "班级成员管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(DeptBan deptBan)
	{		
		return toAjax(deptBanService.insertDeptBan(deptBan));
	}

	/**
	 * 修改班级成员管理
	 */
	@GetMapping("/edit/{deptId}")
	public String edit(@PathVariable("deptId") Integer deptId, ModelMap mmap)
	{
		DeptBan deptBan = deptBanService.selectDeptBanById(deptId);
		mmap.put("deptBan", deptBan);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存班级成员管理
	 */
	@RequiresPermissions("module:deptBan:edit")
	@Log(title = "班级成员管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(DeptBan deptBan)
	{		
		return toAjax(deptBanService.updateDeptBan(deptBan));
	}
	
	/**
	 * 删除班级成员管理
	 */
	@RequiresPermissions("module:deptBan:remove")
	@Log(title = "班级成员管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(deptBanService.deleteDeptBanByIds(ids));
	}
	
}
